import time
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By

from common.Utils import BlogDriver

#博客详情页测试用例

class BlogEdit:
    url=''
    driver=''
    def __init__(self):
        self.url="http://8.137.19.140:9090/blog_edit.html"
        self.driver=BlogDriver.driver
        self.driver.get(self.url)
    #成功发布博客（登录状态下
    def EditSucByLogin(self):
        #找到标题输入
        self.driver.find_element(By.CSS_SELECTOR,"#title").send_keys("aaaa")
        #点击发布按钮
        self.driver.find_element(By.CSS_SELECTOR, "#submit").click()
        #检查是否发布成功
        #滚动到页面最底端
        self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
        actual=self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div:nth-child(51) > div.title").text
        assert actual=="aaaa"
        #添加屏幕截图
        time.sleep(1)
        BlogDriver.getScreenShot()